/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.opgea.crm.domain.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.opgea.crm.domain.entities.security.CrmUser;

/**
 *
 * @author Admin
 */
@Entity
@Table(name = "activity")
@NamedQueries({
    @NamedQuery(name = "Activity.findAll", query = "SELECT a FROM Activity a")})
public class Activity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
   
    @Column(name = "id", nullable = false)
    private Long id;
    @ManyToOne
    @JoinColumn(name = "activityType")
    private SetupsValue activityType;
    @Column(name = "scheduledDate")
    @Temporal(TemporalType.DATE)
    private Date scheduledDate;
    @Column(name = "duration")
    private Integer duration;
    @ManyToOne
    @JoinColumn(name = "activityStatus")
    private SetupsValue activityStatus;
    @Lob
    @Column(name = "note", length = 2147483647)
    private String note;
    @JoinColumn(name = "priority")
    private SetupsValue priority;

    @Column(name = "reminderDate")
    @Temporal(TemporalType.DATE)
    private Date reminderDate;
   
    @JoinColumn(name = "activityStage")
    private SetupsValue activityStage;
    @Column(name = "subject")
    private String subject;
    
    @JoinColumn(name = "relatedOpportunity", referencedColumnName = "id")
    @ManyToOne
    private Opportunity opportunity;
    
    @JoinColumn(name = "relatedContact", referencedColumnName = "id")
    @ManyToOne
    private Lead lead;
    
    @JoinColumn(name = "assignTo", referencedColumnName = "id")
    @ManyToOne
    private Employee assignTo;
    
    @ManyToOne(cascade=CascadeType.REFRESH)
    @JoinColumn(name="createdBy", referencedColumnName="username")
    private CrmUser createdBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="createdat")
    private Date createdAt;

    public Activity() {
    }

    public Activity(Long id) {
        this.id = id;
    }

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public SetupsValue getActivityType() {
		return activityType;
	}

	public void setActivityType(SetupsValue activityType) {
		this.activityType = activityType;
	}

	public Date getScheduledDate() {
		return scheduledDate;
	}

	public void setScheduledDate(Date scheduledDate) {
		this.scheduledDate = scheduledDate;
	}

	public Integer getDuration() {
		return duration;
	}

	public void setDuration(Integer duration) {
		this.duration = duration;
	}

	public SetupsValue getActivityStatus() {
		return activityStatus;
	}

	public void setActivityStatus(SetupsValue activityStatus) {
		this.activityStatus = activityStatus;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public SetupsValue getPriority() {
		return priority;
	}

	public void setPriority(SetupsValue priority) {
		this.priority = priority;
	}


	public Date getReminderDate() {
		return reminderDate;
	}

	public void setReminderDate(Date reminderDate) {
		this.reminderDate = reminderDate;
	}

	public SetupsValue getActivityStage() {
		return activityStage;
	}

	public void setActivityStage(SetupsValue activityStage) {
		this.activityStage = activityStage;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public Opportunity getOpportunity() {
		return opportunity;
	}

	public void setOpportunity(Opportunity opportunity) {
		this.opportunity = opportunity;
	}

	public Lead getLead() {
		return lead;
	}

	public void setLead(Lead lead) {
		this.lead = lead;
	}

	

	public Employee getAssignTo() {
		return assignTo;
	}

	public void setAssignTo(Employee assignTo) {
		this.assignTo = assignTo;
	}

	public void setCreatedBy(CrmUser createdBy) {
		this.createdBy = createdBy;
	}

	public CrmUser getCreatedBy() {
		return createdBy;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	public Date getCreatedAt() {
		return createdAt;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Activity other = (Activity) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Activity [id=" + id + ", activityType=" + activityType
				+ ", scheduledDate=" + scheduledDate + ", duration=" + duration
				+ ", activityStatus=" + activityStatus + ", note=" + note
				+ ", priority=" + priority + ", reminderDate=" + reminderDate
				+ ", activityStage=" + activityStage + ", subject=" + subject
				+ ", opportunity=" + opportunity + ", lead=" + lead
				+ ", assignTo=" + assignTo + ", createdBy=" + createdBy
				+ ", createdAt=" + createdAt + "]";
	}
  
}
